package org.brudywr.mychat.service;

import org.brudywr.mychat.dao.MessageEntity;
import org.brudywr.mychat.dao.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

/**
 * @author stas
 * @since 9/3/13
 */
@Service
public class MyChatRoomServiceImpl implements MyChatRoomService {

    @Transactional
    @Override
    public void addMessage(String nick, String message) {
        MessageEntity entity = new MessageEntity();
        entity.setNick(nick);
        entity.setMessage(message);
        repository.addMessage(entity);
    }

    @Transactional
    @Override
    public Collection<MessageEntity> getAllMessages() {
        return null;
    }

    @Autowired
    private MessageRepository repository;


}
